﻿using System;
using System.Collections.Generic;
using System.IO;
using Newtonsoft.Json.Linq;
using XZDFramework.json;

namespace SourcesUnPacker.role
{
    public class RoleReader
    {
        public const string PATH = "F:\\IosIPA\\ReadMoon";

        public static void test()
        {
            var json = File.ReadAllText(PATH + "\\data.json");
            //json序列化
            JObject jsonObject = JObject.Parse(json);
            var roleDatas = new List<Role>();
            JArray roleArray = (JArray)jsonObject["26bef1"];
            // 从索引 1 开始迭代，跳过第一个列表
            for (int i = 1; i < roleArray.Count; i++)
            {
                JArray skillItem = (JArray)roleArray[i];
                var role = new Role(skillItem);
                roleDatas.Add(role);
            }

            // var JsonHelper.ToString(roleDatas);
            //将数据写到一个json文件里
            File.WriteAllText(PATH + "\\role.json", JsonHelper.ToString(roleDatas));
            Console.WriteLine(JsonHelper.ToString(roleDatas[0]));
        }
    }
}